<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부
	word		= Request("findWord")
	
	setUser	= Request("setUser")	'권한 위임

	SQLTitle = "-- ■■■■ 그룹웨어 자유게시판 그리드 List up ■■■■"	
	
	userId		= Request.Cookies("S_uid")
	
	'## 검색조건에 따른 조건절 만들기 
	If word <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " (A.titles LIKE '%" & word & "%' OR A.contents LIKE '%" & word & "%') "
	End If 
	If addSql <> "" Then addSql = " AND " & addSql
	addSql = " WHERE A.flag='Y' "  & addSql

	SQL = "SELECT A.seq, A.titles, A.hit, A.files, B.userNm, CONVERT(varchar(16), A.issueDt, 121) wDate, C.cnt tailCnt  " & _
			"	FROM tblFreeBoard A LEFT JOIN tblUser B ON A.userId=B.userId " & _
			"					LEFT JOIN (SELECT ISNULL(count(*),'') cnt, seq FROM tblFreeBoardTail WHERE flag='Y' GROUP BY seq) C ON A.seq=C.seq " & addSql & _
			" 	ORDER BY noticeFlag DESC, issueDt  "
			
	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Rs.open SQL, DbCon, 1
	
	Response.write "<BbsList>" & vbcrlf

	If Rs.eof Or Rs.bof Then 
	Else 
		Do Until Rs.eof Or Rs.bof
			
			Response.write "	<Bbs>" & vbcrlf
				Call mkXMLNode("seq", rs("seq"), 2)
				Call mkXMLNode("titles", rs("titles"), 2)
				Call mkXMLNode("hit", rs("hit"), 2)
				Call mkXMLNode("files", rs("files"), 2)
				Call mkXMLNode("userNm", rs("userNm"), 2)
				Call mkXMLNode("wDate", right(rs("wDate"),11), 2)
				Call mkXMLNode("tailCnt", rs("tailCnt"), 2)
			Response.write "	</Bbs>" & vbcrlf

		Rs.movenext
		Loop 
	End If
	Response.write "</BbsList>" & vbcrlf
'	Call rsWithXML("Save OK!")
%>